package com.tom.jmgd.service.impl;

import com.tom.jmgd.dao.TPdHMapper;
import com.tom.jmgd.dao.huobanSyncDataDao;
import com.tom.jmgd.entity.param.TPdH;
import com.tom.jmgd.service.PdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

@Service
public class PdServiceImpl implements PdService {
    @Autowired
    TPdHMapper tPdHMapper;

    @Autowired
    huobanSyncDataDao huobanSyncDataDao1;

    @Override
    public void pdhCreate(TPdH tPdH) {
        tPdH.setCreateDatetime(LocalDateTime.now());
        tPdHMapper.insert1(tPdH);
        System.out.println(tPdH.getPdId());

    }

    @Async
    @Override
    public void syncPd(TPdH tPdH) {
        Map<String, Object> params = new HashMap<>();
        params.put("phId", tPdH.getPdId());
        params.put("busno", tPdH.getBusno());
        params.put("empName", tPdH.getCreateEmpname());
        if("Q".equals(tPdH.getType())){
            huobanSyncDataDao1.syncPdH(params);
        }else if("M".equals(tPdH.getType())){
            huobanSyncDataDao1.syncPdHByMakeno(params);
        }

    }





}
